package com.prs.crm.dao.document.report.Impl;

import java.util.Collection;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.document.report.ReportFormCenterDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.document.report.ReportFormCenter;

public class ReportFormCenterDaoImpl extends BaseDaoImpl<ReportFormCenter> implements ReportFormCenterDao{

	@SuppressWarnings("unchecked")
	@Override
	public Collection<ReportFormCenter> getRootReportFormCenter() {
		Criteria criteria=this.getSession().createCriteria(ReportFormCenter.class);
		criteria.add(Restrictions.isNull("parent"));
		criteria.add(Restrictions.isNull("jspPath"));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ReportFormCenter> getReportFormCenter() {
		Criteria criteria=this.getSession().createCriteria(ReportFormCenter.class);
		criteria.add(Restrictions.isNull("jspPath"));
		return criteria.list();
	}

	@Override
	public int removeReport(Integer id) {
		Query query=this.getSession().createQuery("delete from ReportFormCenter where id="+id);
		return query.executeUpdate();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<ReportFormCenter> getAllReportFormCenter() {
		Criteria criteria=this.getSession().createCriteria(ReportFormCenter.class);
		return criteria.list();
	}

}
